package com.marco.controller.system;

import com.marco.service.system.HomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * HomePageController.java
 * Create on 2017/1/23
 * Copyright(c) JD Inc. All Rights Reserved.
 * <pre>
 * 功能说明：系统主页相关Controller
 * </pre>
 */
@Controller
@RequestMapping("/")
public class HomePageController {
    private final HomePageService homePageService;

    @Autowired
    public HomePageController(HomePageService homePageService) {
        this.homePageService = homePageService;
    }


    @RequestMapping
    @ResponseBody
    public ModelAndView init(HttpServletRequest request) {
        ModelAndView mv = new ModelAndView("/system/index");
        mv.addObject("user", homePageService.welcome(request).get("user"));
        return mv;
    }
}
